Block quotes
A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character >
together with a following space, or (b) a single character >
not followed by a space.
The following rules define block quotes:
- Basic case. If a string of lines Ls constitute a sequence of blocks Bs, then the result of prepending a block quote marker to the beginning of each line in Ls is a block quote containing Bs.
- Laziness. If a string of lines Ls constitute a block quote with contents Bs, then the result of deleting the initial block quote marker from one or more lines in which the next non-whitespace character after the block quote marker is paragraph continuation text is a block quote with Bs as its content. Paragraph continuation text is text that will be parsed as part of the content of a paragraph, but does not occur at the beginning of the paragraph.
- Consecutiveness. A document cannot contain two block quotes in a row unless there is a blank linebetween them.
Nothing else counts as a block quote.
Here is a simple example:
Example 206
Markdown | HTML | Demo |
---|---|---|
|
|
The spaces after the >
characters can be omitted:
Example 207
Markdown | HTML | Demo |
---|---|---|
|
|
The >
characters can be indented 1-3 spaces:
Example 208
Markdown | HTML | Demo |
---|---|---|
|
|
Four spaces gives us a code block:
Example 209
Markdown | HTML | Demo |
---|---|---|
|
|
The Laziness clause allows us to omit the >
before paragraph continuation text:
Example 210
Markdown | HTML | Demo |
---|---|---|
|
|
A block quote can contain some lazy and some non-lazy continuation lines:
Example 211
Markdown | HTML | Demo |
---|---|---|
|
|
Laziness only applies to lines that would have been continuations of paragraphs had they been prepended with block quote markers. For example, the >
cannot be omitted in the second line of
> foo
> ---
without changing the meaning:
Example 212
Markdown | HTML | Demo |
---|---|---|
|
|
Similarly, if we omit the >
in the second line of
> - foo
> - bar
then the block quote ends after the first line:
Example 213
Markdown | HTML | Demo |
---|---|---|
|
|
For the same reason, we can’t omit the >
in front of subsequent lines of an indented or fenced code block:
Example 214
Markdown | HTML | Demo |
---|---|---|
|
|
Example 215
Markdown | HTML | Demo |
---|---|---|
|
|
Note that in the following case, we have a lazy continuation line:
Example 216
Markdown | HTML | Demo |
---|---|---|
|
|
To see why, note that in
> foo
> - bar
the - bar
is indented too far to start a list, and can’t be an indented code block because indented code blocks cannot interrupt paragraphs, so it is paragraph continuation text.
A block quote can be empty:
Example 217
Markdown | HTML | Demo |
---|---|---|
|
|
Example 218
Markdown | HTML | Demo |
---|---|---|
|
|
A block quote can have initial or final blank lines:
Example 219
Markdown | HTML | Demo |
---|---|---|
|
|
A blank line always separates block quotes:
Example 220
Markdown | HTML | Demo |
---|---|---|
|
|
(Most current Markdown implementations, including John Gruber’s original Markdown.pl
, will parse this example as a single block quote with two paragraphs. But it seems better to allow the author to decide whether two block quotes or one are wanted.)
Consecutiveness means that if we put these block quotes together, we get a single block quote:
Example 221
Markdown | HTML | Demo |
---|---|---|
|
|
To get a block quote with two paragraphs, use:
Example 222
Markdown | HTML | Demo |
---|---|---|
|
|
Block quotes can interrupt paragraphs:
Example 223
Markdown | HTML | Demo |
---|---|---|
|
|
In general, blank lines are not needed before or after block quotes:
Example 224
Markdown | HTML | Demo |
---|---|---|
|
|
However, because of laziness, a blank line is needed between a block quote and a following paragraph:
Example 225
Markdown | HTML | Demo |
---|---|---|
|
|
Example 226
Markdown | HTML | Demo |
---|---|---|
|
|
Example 227
Markdown | HTML | Demo |
---|---|---|
|
|
It is a consequence of the Laziness rule that any number of initial >
s may be omitted on a continuation line of a nested block quote:
Example 228
Markdown | HTML | Demo |
---|---|---|
|
|
Example 229
Markdown | HTML | Demo |
---|---|---|
|
|
When including an indented code block in a block quote, remember that the block quote marker includes both the >
and a following space. So five spaces are needed after the >
:
Example 230
Markdown | HTML | Demo |
---|---|---|
|
|